From 5ca183fe88eac6d251ace4be054f0865831e7086 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 8 Apr 2025 15:32:36 +0100 Subject: [PATCH] breakManager: Rework notification urgency setting and presentation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Move the setting of the notification’s urgency, and adding the notification to the queue, to beside where the notification is created. This avoids the potential for changing the urgency of an existing notification if none of the branches above are taken, and `this._notification` is non-empty. Spotted by Florian Müllner in https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3687#note_2405781. Signed-off-by: Philip Withnall Part-of: --- js/misc/breakManager.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/misc/breakManager.js b/js/misc/breakManager.js index d9b1cb3d6..65b740930 100644 --- a/js/misc/breakManager.js +++ b/js/misc/breakManager.js @@ -1100,6 +1100,7 @@ class BreakNotificationSource extends GObject.Object { title: titleText, body: bodyText, sound: null, + urgency: this._urgencyForBreakType(nextBreakType), allowDelay: true, allowSkip: true, allowTake: false, @@ -1228,10 +1229,12 @@ class BreakNotificationSource extends GObject.Object { title: titleText, body: bodyText, sound: null, + urgency: this._urgencyForBreakType(nextBreakType), allowDelay: true, allowSkip: false, allowTake: true, }); + this._source.addNotification(this._notification); this._scheduleUpdateState(BREAK_OVERDUE_TIME_SECONDS); } else if (breakDueAgo >= BREAK_OVERDUE_TIME_SECONDS && @@ -1248,10 +1251,12 @@ class BreakNotificationSource extends GObject.Object { title: _('Break Overdue'), body: bodyText, sound: null, + urgency: this._urgencyForBreakType(nextBreakType), allowDelay: true, allowSkip: false, allowTake: true, }); + this._source.addNotification(this._notification); this._scheduleUpdateState(updateTimeoutSeconds); } else if (this._previousState === BreakState.IN_BREAK) { @@ -1268,19 +1273,16 @@ class BreakNotificationSource extends GObject.Object { title: _('Break Interrupted'), body: bodyText, sound: null, + urgency: this._urgencyForBreakType(nextBreakType), allowDelay: false, allowSkip: false, allowTake: false, }); + this._source.addNotification(this._notification); this._scheduleUpdateState(updateTimeoutSeconds); } - if (this._notification) { - this._notification.urgency = this._urgencyForBreakType(this._manager.currentBreakType); - this._source.addNotification(this._notification); - } - break; } -- 2.39.5